package com.cwj.algorithm.graph;

/**
 * @author chenwujie
 * @date 2020-12-24 08:35
 */
public class Edge implements Comparable<Edge> {
    private int v;
    private int w;
    private int weight;

    public Edge(int v, int w, int weight){
        this.v = v;
        this.w = w;
        this.weight = weight;
    }

    @Override
    public int compareTo(Edge edge) {
        return Integer.compare(weight, edge.weight);
    }

    public int getWeight() {
        return weight;
    }

    /**
     * 获取该顶点对应的另一顶点
     * @param v
     * @return
     */
    public int other(int v){
        return (this.v ^ this.w) ^ v;
    }

    public int getV() {
        return v;
    }

    public int getW() {
        return w;
    }
}
